<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const getList = ([x, ...y]) => [x, y]
        // 对于箭头函数，如果只返回一个值，我们不必编写花括号。但是，如果您想从一个箭头函数返回一个对象，您必须在圆括号之间编写它，否则不会返回任何值!
        const getUser = user => { name: user.name, age: user.age }
        // const getUser = user => ({ name: user.name, age: user.age })
        // [1, [2, 3, 4]]
        const list = [1, 2, 3, 4]
        // undefined
        const user = { name: "Lydia", age: 21 }

        console.log(getList(list))
        console.log(getUser(user))
    </script>
</body>

</html>